<template>
  <div class="app-container">
    <div class="filter-container">

      <el-input
        v-model="listQuery.widlinks"
        type="textarea"
        placeholder="请输入精准留言WID或粘贴链接"
        clearable
        style="width:600px;height:70px;"
        class="filter-item"
      />
      <br/>
      <el-button-group class="filter-item">
        <el-button
          size="small"
          type="primary"
          icon="el-icon-search"
          @click="search"
        >
          搜索
        </el-button>
        <el-button
          size="small"
          type="primary"
          icon="el-icon-refresh"
          @click="refresh"
        >
          重置
        </el-button>

      </el-button-group>
    </div>
    <div v-loading="loading" style="height: calc(100% - 60px);overflow: hidden">
      <div v-if="wzdata.wid>0" class="wzinfoData">
        <div class="infoData">
          <div class="titleH">
            <a class="title" :href="`https://wz.mala.cn/wz/wzinfo?wid=${wzdata.wid}`" target="_blank"><i
              class="el-icon-link"
            ></i> {{ wzdata.title }}</a>
            <div>
              <!--              <span class="status">{{ wzdata.statusText }}</span>-->
              <i class="el-icon-edit status" @click="editTitle"> 编辑标题</i>
              <i class="el-icon-refresh-left status" @dblclick="deleteWid('ref')" v-if="wzdata.delete_time>0"> 恢复</i>
              <i class="el-icon-delete status" @dblclick="deleteWid('del')" v-else> 删除</i>
            </div>
          </div>
          <el-descriptions class="margin-top" :column="3" border style="margin-top:20px;">
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                发帖人
              </template>
              {{ wzdata.u_name }}（{{ wzdata.come_from }}）
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-time"></i>
                时间
              </template>
              {{ wzdata.create_time }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-mobile-phone"></i>
                手机
              </template>
              {{ wzdata.phone }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-tickets"></i>
                当前状态
              </template>
              {{ wzdata.statusText }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-mobile-phone"></i>
                手机是否公开
              </template>
              {{ wzdata.is_zhanshi == 1 ? '公开' : '不公开' }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-time"></i>
                ip
              </template>
              {{ wzdata.ip }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-time"></i>
                截止时间
              </template>
              {{ wzdata.endTime }}
            </el-descriptions-item>
            <el-descriptions-item v-if="wzdata.address">
              <template slot="label">
                <i class="el-icon-office-building"></i>
                精确地址
              </template>
              {{ wzdata.address }}
            </el-descriptions-item>
          </el-descriptions>


          <el-collapse style="margin-top:20px;" v-model="activeNames">
            <el-collapse-item name="1">
              <template slot="title">
                <div style="font-weight: bold;">留言正文内容</div>
              </template>
              <div>

                <div v-html="wzdata.content" @dblclick.stop="editContent=true" v-if="!editContent"
                     v-loading="editContentloading" class="wzdataContent" ref="ContentBox"
                >
                </div>
                <div v-if="editContent">
                  <el-input type="textarea" v-model="editContentParms" rows="10" class="filter-item"
                  ></el-input>
                  <el-popconfirm

                    placement="top"
                    title="留言修改将会直接生效，请问是否确认修改内容？"
                    @confirm="handeleditContent(1)"
                    @cancel="handeleditContent(2)"
                  >
                    <el-button slot="reference" type="primary" size="mini" style="margin-top: 10px">
                      确认修改
                    </el-button>
                  </el-popconfirm>
                  <el-button slot="reference" @click="handeleditContent(2)" type="info" size="mini"
                             style="margin:10px 0 0 10px"
                  >
                    取消
                  </el-button>
                </div>
                <div v-if="wzdata.reply && wzdata.reply.length>0" class="reply">
                  <div :class="['reply-item',item.delete_time>0?'delete_item':'']" v-for="(item,idx) in wzdata.reply">

                    <div class="headerLine">
                      <div class="reply-user">
                      <span class="user">
                        <span v-if="item.delete_time>0" class="delete">已删除</span>
                           {{ item.user_name || item.user_verify }}
                      </span>
                        <span class="t">{{ item.create_time }}</span>
                      </div>

<!--                      <div class="actionButton" @click="actionReply(item.delete_time)">-->
<!--                        {{ item.delete_time > 0 ? '恢复' : '删除' }}-->
<!--                      </div>-->

                      <el-popconfirm
                        :title="`确认删除这个回复吗？删除后可恢复`"
                        class="actionButton"
                        placement="top-end"
                        v-if="item.delete_time==0"
                        @confirm="delReply(item.id,1)"
                      >
                        <span slot="reference">删除</span>
                      </el-popconfirm>
                      <el-popconfirm
                        :title="`确认恢复这个回复吗？？`"
                        class="actionButton"
                        placement="top-end"
                        v-if="item.delete_time>0"
                        @confirm="delReply(item.id,2)"
                      >
                        <span slot="reference">恢复</span>
                      </el-popconfirm>
                    </div>

                    <div v-html="item.l_reply" style="padding-top:5px;color:#666;"></div>
                  </div>
                </div>
              </div>
            </el-collapse-item>
            <el-collapse-item name="2" v-if="wzdata.image &&wzdata.image.length">
              <template slot="title">
                <div style="font-weight: bold;">留言图片</div>
              </template>
              <div class="image__preview">
                <el-image
                  style="width: 100px; height: 100px;object-fit: cover;margin-right:10px;"
                  :src="item"
                  v-for="(item,idx) in wzdata.image"
                  :preview-src-list="wzdata.image"
                >
                </el-image>
              </div>
            </el-collapse-item>

            <el-collapse-item name="3">
              <template slot="title">
                <div class="head">
                  <div style="font-weight: bold;">自动化TAG</div>
                  <div class="icon" @click.stop="getTag"><i
                    :class="[updateLoading.tag?'el-icon-loading':'el-icon-refresh-left']"
                  ></i>重新获取
                  </div>
                </div>
              </template>
              <div class="taglist">
                <template>
                  <el-popconfirm
                    :title="`确认删除【${tag.name}】标签吗？`"
                    v-for="tag in wzdata.taglist"
                    style="margin:0 15px 15px 0"
                    @confirm="deleteTag(tag.id)"
                  >
                    <el-button slot="reference" class="tagbutton">{{ tag.name }} <i
                      class="el-tag__close el-icon-close"
                    /></el-button>
                    </el-tag>
                  </el-popconfirm>
                </template>
              </div>
            </el-collapse-item>

          </el-collapse>
        </div>
        <div class="action">
          <div class="rightFixed">
            <el-collapse style="margin-top:20px;" v-model="activeNames2" accordion>
              <el-collapse-item name="1">
                <template slot="title">
                  <div style="font-weight: bold;">各项状态修改</div>
                </template>
                <div>

                  <el-form v-loading="updateLoading.parms" ref="form" :model="form" label-width="150px">
                    <el-form-item label="留言分类">
                      <el-select v-model="form.type" placeholder="请选择留言分类">
                        <el-option :label="item.label" :value="item.value" v-for="(item,idx) in  wzdata.typeAry"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="留言状态">
                      <el-select v-model="form.status" placeholder="请选择该留言状态">
                        <el-option :label="item" :value="idx" v-for="(item,idx) in  wzdata.statusAry"></el-option>
                      </el-select>
                    </el-form-item>

                    <el-form-item label="留言领域">
                      <el-cascader
                        v-model="form.classify2"
                        :options="wzdata.lingyuAry"
                        :props="{ expandTrigger: 'hover' }"
                        @change="handleChangelingyu"
                      ></el-cascader>
                    </el-form-item>


                    <el-form-item label="标记不导出">
                      <el-switch v-model="form.export_status"></el-switch>
                    </el-form-item>
                    <el-form-item label="是否公开手机">
                      <el-switch v-model="form.is_zhanshi"  :active-value="1" :inactive-value="2"></el-switch>
                    </el-form-item>
                    <el-form-item label="不统计满意度">
                      <el-switch v-model="form.myd_status"></el-switch>
                    </el-form-item>
                    <el-form-item label="仅作者和单位可见">
                      <el-switch v-model="form.bkj_status"></el-switch>
                    </el-form-item>


                    <el-form-item label="首页展示">
                      <el-switch v-model="form.is_index"></el-switch>
                    </el-form-item>

                    <el-form-item>
                      <el-button type="primary" @click="onSubmit">提交修改</el-button>
                      <el-button @click="refsumit">重置</el-button>
                    </el-form-item>

                  </el-form>

                </div>
              </el-collapse-item>

              <el-collapse-item name="2">
                <template slot="title">
                  <div class="head" style="display: flex; width: 100%;">
                    <div style="font-weight: bold;">发帖时间</div>
                    <div class="icon" style="color:#999;margin-left:50px;">{{ wzdata.create_time }}
                    </div>
                  </div>
                </template>
                <div>
                  <el-form ref="form" :model="form" label-width="150px">
                    <div v-loading="wzdataUpdateloading.create_time">
                      <el-form-item label="发帖时间" style="margin-top:20px;">
                        <el-date-picker
                          v-model="form.create_time"
                          type="datetime"
                          placeholder="选择发帖时间"
                          value-format="yyyy-MM-dd HH:mm:ss"
                        >
                        </el-date-picker>
                      </el-form-item>
                      <el-form-item>
                        <el-button type="primary" @click="onSubmitwzData(1)">提交修改</el-button>
                        <el-button @click="refsumitwzData">重置</el-button>
                      </el-form-item>
                    </div>
                  </el-form>
                </div>
              </el-collapse-item>
              <el-collapse-item name="3">
                <template slot="title">
                  <div class="head" style="display: flex; width: 100%;">
                    <div style="font-weight: bold;">延长截止时间</div>
                    <div class="icon" style="color:#999;margin-left:50px;">{{ wzdata.endTime }}
                    </div>
                  </div>
                </template>
                <div>
                  <el-form ref="form" :model="formdata" label-width="150px">
                    <div v-loading="updateLoading.date">
                      <el-form-item label="过期截止时间" style="margin-top:20px;">
                        <el-date-picker
                          v-model="formdata.endTime"
                          type="datetime"
                          placeholder="选择过期截止时间"
                        >
                        </el-date-picker>
                        <p style="color:#999;font-size:12px">选择59:59秒，程序会自动+1s</p>
                      </el-form-item>
                      <el-form-item label="延期理由" style="margin-top:20px;">
                        <el-input type="textarea" v-model="formdata.endTime_reason" rows="3"></el-input>
                      </el-form-item>
                      <el-form-item>
                        <el-button type="primary" @click="onSubmitdate(1)">提交修改</el-button>
                        <el-button type="success" @click="onSubmitdate(2)">恢复自动计算</el-button>
                        <el-button @click="refsumitdate">重置</el-button>
                      </el-form-item>
                    </div>
                  </el-form>
                </div>
              </el-collapse-item>

              <el-collapse-item name="4">
                <template slot="title">
                  <div style="font-weight: bold;">评分修改</div>
                </template>
                <div v-loading="loadingStatus.rate">
                  <el-form ref="form" :model="formstar">
                    <el-form-item label="答复速度">
                      <el-rate v-model="formstar.evaluate_speed" :show-score="true" style="line-height: 2.6"
                               @change="changerate"
                      ></el-rate>
                    </el-form-item>

                    <el-form-item label="答复质量">
                      <el-rate v-model="formstar.evaluate_quality" :show-score="true" style="line-height: 2.6"
                               @change="changerate"
                      ></el-rate>
                    </el-form-item>

                    <el-form-item label="满意程度">
                      <el-rate v-model="formstar.evaluate_satisfied" :show-score="true" style="line-height: 2.6"
                               @change="changerate"
                      ></el-rate>
                    </el-form-item>

                    <el-form-item label="最终评分 ">
                      <el-rate v-model="formstar.evaluate_all" :show-score="true" style="line-height: 2.6;" disabled
                      ></el-rate>
                    </el-form-item>
                    <el-form-item label="不满意理由">
                      <el-input type="textarea" v-model="formstar.bmy_reason" rows="3"></el-input>
                    </el-form-item>
                    <el-form-item>
                      <el-button type="primary" @click="onSubmitrate">提交修改</el-button>
                      <el-button type="success" @click="clearrate">清空评分</el-button>
                      <el-button @click="refsumitrate">重置</el-button>
                    </el-form-item>

                  </el-form>

                </div>
              </el-collapse-item>

              <el-collapse-item name="5">
                <template slot="title">
                  <div style="font-weight: bold;">选登状态</div>
                </template>
                <div v-loading="loadingStatus.xuandeng">
                  <el-form ref="form" :model="formstar">
                    <el-form-item label="选登状态">
                      <el-select v-model="form.xuandeng" placeholder="请选择选登状态">
                        <el-option :label="item" :value="idx" v-for="(item,idx) in  ['不选登','选登并置顶','普通选登']"></el-option>
                      </el-select>
                    </el-form-item>


                    <el-form-item>
                      <el-button type="primary" @click="onSubmitxuandeng">提交选登</el-button>
                    </el-form-item>

                  </el-form>

                </div>
              </el-collapse-item>

            </el-collapse>


          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<style scoped lang="less">
.formstar {
  display: flex;
}

.image__preview {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
}

.wzdataContent {
  position: relative;
  overflow: hidden;
}

.wzinfoData {
  display: flex;
  border: 1px solid #eee;
  height: 100%;

  .other {
    background: #bdd7eb45;
    padding: 10px;
    margin-top: 10px;
    border-radius: 5px;

    h3 {
      margin: 0;
      padding: 0;
      font-size: 14px;
      color: #888;
    }
  }

  .infoData {
    width: calc(60% - 30px);
    padding: 30px;
    border-right: 1px solid #eee;
    height: 100%;
    overflow-y: scroll;

    &::-webkit-scrollbar {
      width: 3px;
      height: 1px;
    }

    &::-webkit-scrollbar-thumb { /*滚动条里面小方块*/
      //border-radius: 10px;
      -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
      background: #aaa;
    }

    &::-webkit-scrollbar-track { /*滚动条里面轨道*/
      -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
      //border-radius: 10px;
      background: #fefefe;
    }

    .postInfo {
      display: flex;
      width: 100%;
      justify-content: space-between;
      font-size: 12px;
      color: #aa9;
      flex-wrap: wrap;
      margin-top: 10px;

      > div {
        margin-bottom: 5px;
        width: 50%;

        > span {
          color: #666;
        }
      }
    }

    .titleH {
      display: flex;
      justify-content: space-between;

      .status {
        margin-left: 30px;
        //background: red;
        color: #444;
        cursor: pointer;
        padding: 3px 10px;
        font-size: 18px;
        font-weight: bold;

        &.el-icon-delete {

          font-size: 18px;
          padding: 4px 10px;
        }
      }
    }

    .title {
      color: #20a0ff;
      font-size: 22px;
      font-weight: bold;

      &:hover {
        color: #369;
      }
    }

    .head {
      display: flex;
      width: 100%;

      .icon {
        margin-left: 20px;
        color: #777;

        i:before {
          margin-right: 3px;
        }
      }
    }

    .taglist {
      display: flex;
      flex-wrap: wrap;
      color: #888;

      .tagbutton {
        color: #409EFF;
        border-color: #c6e2ff;
        background-color: #ecf5ff;
        padding: 8px 10px;
        border: none
      }

      > div {
        margin-right: 25px;
      }
    }
  }

  .action {
    width: 40%;
    overflow-y: scroll;

    &::-webkit-scrollbar {
      width: 3px;
      height: 1px;
    }

    &::-webkit-scrollbar-thumb { /*滚动条里面小方块*/
      //border-radius: 10px;
      -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
      background: #aaa;
    }

    &::-webkit-scrollbar-track { /*滚动条里面轨道*/
      -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
      //border-radius: 10px;
      background: #fefefe;
    }

    .rightFixed {
      padding: 30px;
    }

    .rightHeadtitle {
      font-size: 18px;
      font-weight: bold;
      padding-bottom: 10px;
      border-bottom: 1px solid #ddd;
      margin-bottom: 10px;
    }
  }

  .editInput {
    border: none !important;
  }

  .reply-item {
    color: #409EFF;
    border-color: #c6e2ff;
    background-color: #ecf5ff;
    padding: 15px;
    margin: 10px 0;
    border-radius: 5px;

    &.delete_item {
      color: #999;
      border-color: #ddd;
      background-color: #eee;

      .headerLine {
        border-bottom: 1px solid #ddd !important;
      }
    }

    .headerLine {
      display: flex;
      justify-content: space-between;
      border-bottom: 1px solid #c6e2ff;

      .actionButton {
        cursor: pointer;
      }
    }

    .reply-user {
      font-weight: bold;
      padding-bottom: 5px;
      display: flex;


      .user .delete {
        background: red;
        color: #fff;
        padding: 2px 5px;
        margin-right: 5px;
        border-radius: 5px;
      }

      .t {
        font-weight: normal;
        color: #999;
        margin-left: 30px;
      }
    }
  }
}
</style>
<script>
import { delWzinfo, getWzinfo, updateTag, updateWzinfo, updateWzinfoParms } from '@/api/wz'

export default {
  data() {
    return {
      total: 0,
      schemeIDForDisplay: 0,
      schemeIDForDisplay_password: '',
      list: [],
      editContent: false,
      editContentloading: false,
      editContentParms: '',
      wzdata: [],
      wid: 0,
      activeNames: ['1', '3'],
      activeNames2: [],
      updateLoading: {
        tag: false,
        date: false,
        parms: false
      },
      wzdataUpdateloading:{
        create_time:false
      },
      wzdataUpdate:[],
      form: [],
      formdata: [],
      formstar: [],
      ContentHeight: [],
      loadingStatus: {
        rate: false,
        xuandeng:false,
      },
      listQuery: {
        widlinks: ''
      },
      loading: false
    }
  },
  created() {
    let wid = this.$route.query.wid
    if (wid) {
      this.listQuery.widlinks = 'https://wz.mala.cn/wz/wzinfo?wid=' + wid
      this.fetchData()
    }
    // this.fetchData()
    // this.handleContent()
  },
  // updated() {
  //   this.$nextTick(() => {
  //     if (this.$refs.ContentBox.offsetHeight > 160) {
  //       this.ContentHeight = '160'
  //     } else {
  //       this.Contentstatus = 'auto'
  //     }
  //   })
  // },
  methods: {
    editTitle() {
      this.$prompt('请输入新标题', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputValue:this.wzdata.title
      }).then(({ value }) => {
        this.loading = true
        updateWzinfoParms({ wid: this.wzdata.wid, action: 'title', title:value }).then(r => {
          this.fetchData()
        }, data => {
        })
      }).catch(() => {})
    },
    changerate() {
      let allCount = ((this.formstar.evaluate_speed + this.formstar.evaluate_quality + this.formstar.evaluate_satisfied) / 3).toFixed(0)
      this.formstar.evaluate_all = allCount
    },
    refsumitrate() {
      this.formstar = {
        evaluate_speed: this.wzdata.evaluate_speed,
        evaluate_quality: this.wzdata.evaluate_quality,
        evaluate_satisfied: this.wzdata.evaluate_satisfied,
        evaluate_all: this.wzdata.evaluate_all,
        bmy_reason: this.wzdata.bmy_reason
      }
    },
    onSubmitrate() {
      this.loadingStatus['rate'] = true
      updateWzinfoParms({ wid: this.wzdata.wid, action: 'rate', ...this.formstar }).then(r => {
        this.loadingStatus.rate = false
        this.fetchData()
      }, data => {
        this.loadingStatus.rate = false
      })
    },
    onSubmitxuandeng() {
      updateWzinfoParms({ wid: this.wzdata.wid, action: 'xuandeng', ...this.form }).then(r => {
        this.loadingStatus.xuandeng = false
        this.fetchData()
      }, data => {
        this.loadingStatus.xuandeng = false
      })
    },
    clearrate() {
      if (!this.wzdata.wid) {
        this.$message({
          type: 'error',
          message: '参数有误!'
        })
      } else {
        this.loadingStatus['rate'] = true
        updateWzinfoParms({ wid: this.wzdata.wid, action: 'clearrate' }).then(r => {
          this.loadingStatus.rate = false
          this.$message({
            type: 'success',
            message: '清空成功!'
          })
          this.fetchData()
        })
      }
    },
    deleteWid(s) {
      if (!this.wzdata.wid) {
        this.$message({
          type: 'error',
          message: '参数有误!'
        })
      } else {
        if (s == 'del') {
          const h = this.$createElement
          this.schemeIDForDisplay = 0
          let _this = this
          const randOm = (Math.round((Math.random() * (999 - 111) + 111) * 10) / 10).toFixed(0)
          this.$msgbox({
            title: '删除提示',
            message: h('div', null, [
              h('el-select', {
                  props: {
                    value: '',
                    placeholder: '请选择删除理由'
                  },
                  ref: 'selectView_' + randOm,
                  on: {
                    change: e => {
                      _this.schemeIDForDisplay = e
                      _this.$refs[`selectView_${randOm}`].value = e
                    }
                  }
                },
                [
                  this.wzdata.delete_reason.map((it, idx) => {
                    if (idx > 0) {
                      return h('el-option', {
                        props: {
                          key: idx,
                          label: it,
                          value: idx
                        }
                      })
                    }
                  })
                ]
              )
            ]),
            showCancelButton: true,
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            beforeClose: (action, instance, done) => {
              if (action === 'confirm') {
                let delete_type = this.schemeIDForDisplay
                if (!delete_type) {
                  this.$message({
                    type: 'error',
                    message: '请选择一个理由!'
                  })
                  return false
                }
                delWzinfo({ wid: this.wzdata.wid, type: delete_type, uid: this.wzdata.uid }).then(r => {
                  this.$message({
                    type: 'success',
                    message: '删除成功!'
                  })
                  done()
                  this.fetchData()
                })
              } else {
                done()
              }
            }
          }).then(action => {
          }).catch(() => {

          })
        } else {
          this.$confirm('该帖文在没有彻底删除可恢复，不代表一定恢复成功', '提示', {
            confirmButtonText: '确定恢复',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            delWzinfo({ wid: this.wzdata.wid, action: 'ref' }).then(r => {
              this.$message({
                type: 'success',
                message: '恢复成功!'
              })
              this.fetchData()
            })
          }).catch(() => {
          })
        }
      }
    },
    handeleditContent(type) {
      this.editContent = false
      if (type == 1) {
        this.editContentloading = true
        updateWzinfo({ wid: this.wzdata.wid, content: this.editContentParms }).then(r => {
          this.editContentloading = false
          this.wzdata.content = this.editContentParms.replace(/\n/g, '<br />')
          this.$message({
            type: 'success',
            message: '修改成功!'
          })
        }, data => {
          this.editContentloading = false
        })
      }
    },
    search() {
      this.fetchData()
    },
    delReply(reply_id,type) {
      this.loading = true
      updateWzinfoParms({ action: 'reply_action', type:type,wid: this.wzdata.wid, reply_id:reply_id }).then(r => {
        this.fetchData()
      })
    },
    deleteTag(tagid) {
      updateTag({ wid: this.wzdata.wid, action: 'delete', 'tag_id': tagid }).then(r => {
        this.wzdata.taglist = r.data
      }, data => {
        this.$message({
          message: '网络超时，请重试',
          type: 'error'
        })
        return false
      })
    },
    getTag() {
      this.updateLoading.tag = true
      this.activeNames.push('3')
      this.wzdata.taglist = []
      updateTag({ wid: this.wzdata.wid, 'action': 'update' }).then(r => {
        this.wzdata.taglist = r.data
        this.updateLoading.tag = false
      }, data => {
        this.updateLoading.tag = false
        this.$message({
          message: '请求百度网络超时，请重试',
          type: 'error'
        })
        return false
      })
    },
    refresh() {
      this.listQuery = {
        widlinks: ''
      }
      this.fetchData()
    },
    handleChangelingyu(data) {
      this.form.classify1 = data[0]
      this.form.classify2 = data[1]
    },
    refsumit() {
      this.form = {
        status: '' + this.wzdata.status + '',
        is_zhanshi: this.wzdata.is_zhanshi > 0 ? true : false,
        export_status: this.wzdata.export_status > 0 ? true : false,
        type: this.wzdata.type,
        classify1: this.wzdata.classify1,
        classify2: this.wzdata.classify2,
        is_index: this.wzdata.is_index > 0 ? true : false,
        myd_status: this.wzdata.myd_status > 0 ? true : false,
        bkj_status: this.wzdata.bkj_status > 0 ? true : false
      }
    },
    onSubmitdate(type) {
      if (type == 1) {
        this.$confirm('此操作将会直接修改过期时间，可能会影响部门KPI考核，是否修改？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.updateLoading.date = true
          updateWzinfoParms({ action: 'endTime', wid: this.wzdata.wid, ...this.formdata }).then(r => {
            this.updateLoading.date = false
            this.fetchData()
          }, data => {
            this.updateLoading.date = false
          })
        }).catch(() => {
        })
      } else {
        this.updateLoading.date = true
        updateWzinfoParms({ action: 'endTime_2', wid: this.wzdata.wid }).then(r => {
          this.updateLoading.date = false
          this.fetchData()
        }, data => {
          this.updateLoading.date = false
        })
      }
    },
    refsumitdate() {
      this.formdata.endTime = this.wzdata.endTime
    },
    refsumitwzData(){
      this.$set(this.form,'create_time',this.wzdata.create_time)
    },
    onSubmitwzData(){
      this.wzdataUpdateloading.create_time = true
      updateWzinfoParms({ action: 'create_time', newData:this.form.create_time,wid: this.wzdata.wid}).then(r => {
        this.wzdataUpdateloading.create_time = false
        this.$message.success('操作成功')
        this.fetchData()
      }, data => {
        this.wzdataUpdateloading.create_time = false
      })
    },
    onSubmit() {

      var defaultForm = this.form
      this.$confirm('此操作将会直接修改帖子各项参数，该操作不可逆并会留下操作记录，是否继续？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.updateLoading.parms = true
        updateWzinfo({ actionStatus: 'status', wid: this.wzdata.wid, ...this.form }).then(r => {
          this.updateLoading.parms = false
        }, data => {
          this.updateLoading.parms = false
        })
      }).catch(() => {

      })
    },
    fetchData() {
      this.loading = true
      if (!isNaN(this.listQuery.widlinks)) {
        this.wid = this.listQuery.widlinks
      } else {
        var regex = /(wid=)+(\d+)/
        var string = this.listQuery.widlinks
        var result = regex.exec(string)
        this.wid = result[2]
      }
      if (!isNaN(this.wid)) {
        getWzinfo({ wid: this.wid }).then(response => {
          this.wzdata = response.data
          this.editContentParms = (response.data.content).replace(/<br \/>/g, '\n')
          this.form = {
            status: '' + response.data.status + '',
            export_status: response.data.export_status > 0 ? true : false,
            type: response.data.type,
            classify1: response.data.classify1,
            classify2: response.data.classify2,
            is_index: response.data.is_index > 0 ? true : false,
            myd_status: response.data.myd_status > 0 ? true : false,
            bkj_status: response.data.bkj_status > 0 ? true : false,
            create_time: response.data.create_time,
            xuandeng:response.data.xuandeng,
          }

          this.formdata = {
            endTime: response.data.endTime,
            endTime_2: response.data.endTime_2,
            endTime_reason: response.data.endTime_reason,
          }
          this.formstar = {
            evaluate_speed: response.data.evaluate_speed,
            evaluate_quality: response.data.evaluate_quality,
            evaluate_satisfied: response.data.evaluate_satisfied,
            evaluate_all: response.data.evaluate_all,
            bmy_reason: response.data.bmy_reason
          }
          this.loading = false
        })
      } else {
        this.$message({
          message: '识别出错，请直接输入wid',
          type: 'error'
        })
        return false
      }

    }
  }
}
</script>
